local yimie = fk.CreateSkill {
    name = "jinhs__yimie",
    tags = { Skill.Compulsory },
}

Fk:loadTranslationTable {
    ["jinhs__yimie"] = "夷灭",
    [":jinhs__yimie"] = "锁定技，你的回合内，处于濒死阶段的角色不能使用【桃】；当你于回合内首次造成伤害时，你失去1点体力并令此伤害+1。",

    ["$jinhs__yimie1"] = "汝大逆不道，当死无赦!",
    ["$jinhs__yimie2"] = "斩草除根，灭其退路！",
}

yimie:addEffect(fk.EnterDying, {
    can_refresh = function(self, event, target, player, data)
        return player:hasShownSkill(yimie.name) and player.room.current == player
    end,
    on_refresh = function(self, event, target, player, data)
        player.room:notifySkillInvoked(player, yimie.name)
        player:broadcastSkillInvoke(yimie.name)
        player.room:addPlayerMark(target, yimie.name)
    end,
})

yimie:addEffect(fk.AfterDying, {
  can_refresh = function(self, event, target, player, data)
    return target:getMark(yimie.name) > 0
  end,
  on_refresh = function(self, event, target, player, data)
    player.room:removePlayerMark(target, yimie.name)
  end,
})

yimie:addEffect("prohibit",{
    prohibit_use = function(self, player, card)
      return card and card.name == "peach" and player:getMark(yimie.name) > 0
    end,
})

yimie:addEffect(fk.DamageCaused, {
    anim_type = "offensive",
    can_trigger = function(self, event, target, player, data)
        return player:hasSkill(yimie.name) and player:isAlive() and data.from == player and
        player:usedEffectTimes(self.name, Player.HistoryTurn) == 0 and player.room.current == player
    end,
    on_use = function(self, event, target, player, data)
        local room = player.room
        if player.dead then return end
        room:loseHp(player, 1, yimie.name)
        data:changeDamage(1)
    end,
})

return yimie
